//
//  GYDMessgeSendView.swift
//  Weibo
//
//  Created by 贵永冬 on 16/7/29.
//  Copyright © 2016年 贵永冬. All rights reserved.
//

import UIKit

class GYDMessgeSendView: UILabel {

    static func showInView(view: UIView, messageNumber: Int) {
        let messageView = GYDMessgeSendView(frame: CGRect(x: 0, y: 0, width: view.width, height: 40))
        messageView.text = "\(messageNumber)条新微博数据"
        messageView.backgroundColor = RGBA(253, g: 168, b: 85, a: 0.8)
        messageView.textColor = UIColor.whiteColor()
        messageView.textAlignment = NSTextAlignment.Center
        messageView.font = UIFont.systemFontOfSize(15)
        view.addSubview(messageView)
        UIView.animateWithDuration(0.7, animations: {
            messageView.top = 64
            }) { (stop) in
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.8*Float(NSEC_PER_SEC))), dispatch_get_main_queue()) {
                    UIView.animateWithDuration(0.5, animations: {
                        messageView.top = 0
                        }, completion: { (stop) in
                            messageView.removeFromSuperview()
                    })
                }
        }
    }
}
